package actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import db.DBModel;
import model.VenueModel;

public class ShowVenueAction extends Action{

	public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response){

		try{
			DBModel db = new DBModel();
			VenueModel venueBean = db.getVenue(Integer.parseInt(request.getParameter("id")));

			request.setAttribute("venueObject", venueBean);
			//request.getRequestDispatcher("venue.jsp?"+venueBean.getId()).forward(request, response);
			db.close();
			return mapping.findForward("success");
		}catch (Exception e){
			e.printStackTrace();
			request.setAttribute("error", e.toString());
			return mapping.findForward("fail");
		}	

	}

}
